package com.gpframework.module.order.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.order.domain.GpProduct;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.math.BigDecimal;

/**
 * @ClassName GpProductReq
 * @Author gpframework
 * @Date 2023-06-16
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class GpProductReq extends BaseReq {
    private static final long serialVersionUID = 1L;

         @ApiModelProperty("品牌id")
     private String brandId;
     @ApiModelProperty("品牌名称")
     private String brandName;
     @ApiModelProperty("订单ID")
     private Long orderId;
     @ApiModelProperty("产品ID")
     private String productId;
     @ApiModelProperty("产品名称")
     private String productName;
     @ApiModelProperty("产品颜色ID")
     private String productColorId;
     @ApiModelProperty("产品颜色")
     private String productColor;
     @ApiModelProperty("批次号")
     private String batchNo;
     @ApiModelProperty("总数量")
     private BigDecimal totalQuantity;
     @ApiModelProperty("总邮寄数量")
     private BigDecimal totalPostQuantity;
     @ApiModelProperty("总分支数量")
     private BigDecimal totalBranchesQuantity;
     @ApiModelProperty("预期金额")
     private BigDecimal expectAmount;
     @ApiModelProperty("单价")
     private BigDecimal unitPrice;
     @ApiModelProperty("产品单位标签名称")
     private String productUnitTagName;
     @ApiModelProperty("产品邮寄单位名称")
     private String productPostUnitName;
     @ApiModelProperty("数量标签")
     private String quantityTag;
     @ApiModelProperty("分支数量")
     private BigDecimal branchesQuantity;
     @ApiModelProperty("数量")
     private BigDecimal quantity;

    /**
    * @Description 生成查询wrapper
    * @Author greatplan@qq.com
    * @Date 2020-11-04 16:04
    * @Param [lqw]
    * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
    * @Return void
    */
    public void generatorQuery(QueryWrapper<GpProduct> lqw,boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias+"del_status",0);
        }
        if (StringUtils.isNotBlank(this.getBrandId())){
        lqw.eq(alias+"brand_id" ,this.getBrandId());
        }
        if (StringUtils.isNotBlank(this.getBrandName())){
            lqw.like(alias+"brand_name",this.getBrandName());
        }
        if (this.getOrderId() != null){
        lqw.eq(alias+"order_id" ,this.getOrderId());
        }
        if (StringUtils.isNotBlank(this.getProductId())){
        lqw.eq(alias+"product_id" ,this.getProductId());
        }
        if (StringUtils.isNotBlank(this.getProductName())){
            lqw.like(alias+"product_name",this.getProductName());
        }
        if (StringUtils.isNotBlank(this.getProductColorId())){
        lqw.eq(alias+"product_color_id" ,this.getProductColorId());
        }
        if (StringUtils.isNotBlank(this.getProductColor())){
        lqw.eq(alias+"product_color" ,this.getProductColor());
        }
        if (StringUtils.isNotBlank(this.getBatchNo())){
        lqw.eq(alias+"batch_no" ,this.getBatchNo());
        }
        if (this.getTotalQuantity() != null){
        lqw.eq(alias+"total_quantity" ,this.getTotalQuantity());
        }
        if (this.getTotalPostQuantity() != null){
        lqw.eq(alias+"total_post_quantity" ,this.getTotalPostQuantity());
        }
        if (this.getTotalBranchesQuantity() != null){
        lqw.eq(alias+"total_branches_quantity" ,this.getTotalBranchesQuantity());
        }
        if (this.getExpectAmount() != null){
        lqw.eq(alias+"expect_amount" ,this.getExpectAmount());
        }
        if (this.getUnitPrice() != null){
        lqw.eq(alias+"unit_price" ,this.getUnitPrice());
        }
        if (StringUtils.isNotBlank(this.getProductUnitTagName())){
            lqw.like(alias+"product_unit_tag_name",this.getProductUnitTagName());
        }
        if (StringUtils.isNotBlank(this.getProductPostUnitName())){
            lqw.like(alias+"product_post_unit_name",this.getProductPostUnitName());
        }
        if (StringUtils.isNotBlank(this.getQuantityTag())){
        lqw.eq(alias+"quantity_tag" ,this.getQuantityTag());
        }
        if (this.getBranchesQuantity() != null){
        lqw.eq(alias+"branches_quantity" ,this.getBranchesQuantity());
        }
        if (this.getQuantity() != null){
        lqw.eq(alias+"quantity" ,this.getQuantity());
        }
    }
}
